var int;
function get_qrcode(){
    $.ajax({
        url:'get_qrcode',
        type:'POST',
        dataType:'JSON',
        success:function(data){
            var imgSrc="data:image/png;base64,"+data.base64;
            var uuid = data.uuid;
            $("#qrcode").attr("src",imgSrc);
            //jquery的轮询函数
           int=self.setInterval(function(){
                roll_poling(uuid);
            },2000);
        }
    });
}

//轮询操作
function roll_poling(uuid){
    $.ajax({
        url:'roll_poling',
        type:'POST',
        data:{uuid:uuid},
        async:false,
        success:function(data){
            console.log("data===="+data);
            if( data == "success" ){
                console.log(data);
                clearInterval(int);
                window.location.href="https://baidu.com";
            }else if(data == "no_exist"){
                clearInterval(int);
                window.location.reload();
            }
        },
        error:function (data) {
            console.log(data);
        }
    });
}
window.onload=get_qrcode();